import { defineStore } from 'pinia'

export const useUser = defineStore('user', {
    state: () => {
        const token = localStorage.getItem('token')
        const userInfo = localStorage.getItem("user") || "{}"
        return {
            token: token || '',
            user: JSON.parse(userInfo)
        }
    },
    actions: {
        clearInfo() {
            this.token = ''
            this.userInfo = "{}"
        }
    }
})